<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0, user-scalable=no" />
<link rel="shortcut icon" href="/Images/ico/favicon.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="/css/swiper.min.css" />
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<link type="text/css" rel="stylesheet" href="/layui/css/layui.css"  media="all">
<script type="text/javascript" src="/layui/layui.js" charset="utf-8"></script>
<script src="/js/jquery.min.js" type="text/javascript"></script>
<script src="/js/swiper.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/layui-post.js"></script>
<style type="text/css">
.layui-layer-content{background:#fff}
.layui-layer-nobg{border-radius: 10px 10px 0 0!important;}
.layui-layer-title{border-radius: 10px 10px 0 0!important;}
</style>
</head>
<body style="background:#eee">
<div class="headerbox">
  <div class="ng-scope">
    <div class="loca ng-scope title-order" style="background: #f9fafd;">
      <a class="title-top" href="javascript:window.history.back();"></a>
      <a class="title-center">设置</a>
      <a class="title-right" href="/index"></a>
    </div>
  </div>
</div>
<div class="jsyhq pad0" style="margin-top: 55px;">
  <div class="jsyhq_2 bor0">
    <a>
      <div class="jsjfL"><p>昵称</p></div>
      <div class="jsjfR" style="width:auto;" onclick="setNickName()">
        <span id="nickNames"></span><img src="images/more.png">
      </div>
      <div class="clear"></div>
    </a>
  </div>
  <div class="kbox"></div>
</div>
<div class="clear"></div>
<!--<div class="tuichu">-->
<!--  <a href="my.html">退出当前帐户</a>-->
<!--</div>-->
<!-- 设置昵称 -->
<div class="modal-dialog" id="orderLog" style="font-size:16px;border-radius: 10px;display: none;background: #fff;padding: 30px;">
  <div class="addr_con">
    <form class="layui-form layui-form-pane">
      <input class="aui-Address-box-input" name="nickName" id="nickName" lay-verify="required" placeholder="请输入姓名或者昵称" type="text">
      <div class="red-color" style="border-radius: 10px;" id="btnSave" lay-submit="" lay-filter="add">保 存</div>
    </form>
  </div>
</div>
</body>
<script>
$.ajaxSetup({contentType: "application/json; charset=utf-8"});
var userInfo = $.parseJSON(sessionStorage.getItem("userInfo"));
layui.use(['layer','form','element','util'], function(){
  $.post("/cateringUser/selectOne",JSON.stringify({opendId:sessionStorage.getItem("opendId")}), function (res) {
    if(res.data != null){
      $("#integral").html(res.data.integral)
      $("#paymoney").html(res.data.payMoney)
      userInfo = res.data;
      sessionStorage.setItem("userInfo", JSON.stringify(res.data));
      if(!isEmpty(res.data.nickName)) {
        $("#nickNames").html(res.data.nickName)
        $("#nickName").val(res.data.nickName)
      } else $("#nickNames").html("设置昵称")
    }
  })
  layui.form.on('submit(add)', function(data){
    data.field.userId = userInfo.userId;
    data.field.sysId = userInfo.sysId;
    $.post("/cateringUser/update",JSON.stringify(data.field),function(res){
      if(res.success) layer.msg(res.msg,{icon:1,time:1500},function(){
        window.location.reload()
      });
    })
  })
})
function setNickName(){
  layer.open({
    type:1,
    area: ['100%', '40%'],
    title:["设置昵称", 'text-align:center;font-size: 16px; font-weight: bold;padding-left: 80px;'],
    closeBtn:1,
    btnAlign: 'c',
    offset: 'b',
    anim: 2,
    skin:'layui-layer-nobg',
    shadeClose:true,
    content:$("#orderLog"),
    scrollbar:false,
  })
}
</script>
</html>
